package com.action;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.dao.ProductTypeDAO;
import com.dao.impl.ProductTypeDAOImpl;


/**
 * Servlet implementation class SelectProductTypeServlet
 */
public class SelectProductTypeServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding("UTF-8");
		ProductTypeDAO ptd = new ProductTypeDAOImpl();
		response.setCharacterEncoding("UTF-8");
		response.getWriter().print(ptd.selectProductType2());
		response.getWriter().flush();
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding("UTF-8");
		String page = request.getParameter("page");
		String rows = request.getParameter("rows");
		String key = request.getParameter("key");
		String type = request.getParameter("type");
		int startPage = Integer.parseInt(page);
		int endRows = Integer.parseInt(rows);
		ProductTypeDAO ptd = new ProductTypeDAOImpl();
		response.setCharacterEncoding("UTF-8");
		response.getWriter().print(ptd.selectProductType(startPage,endRows,key,type));
		response.getWriter().flush();
	}

}
